import java.util.Scanner;

public class 饮料换购 {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        int sum=n;
        int l=0;
        while(n>=3) {
            l=n%3;
            n=n/3;
            sum+=n;
            n+=l;
        }
        System.out.println(sum);

    }
}
